//
//  RBFeedbackVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/3.
//

#import "RBFeedbackVC.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RanTool.h"
#import "UIViewController+RBAdd.h"
#import "RBTextView.h"

@interface RBFeedbackVC ()

@property(nonatomic, strong)RBTextView *textView;

@end

@implementation RBFeedbackVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"问题反馈";
    self.view.backgroundColor = [RBThemeConfig bgGrayColor];
    
    UIView *topView = UIView.new;
    topView.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(Zoom(10));
        make.left.right.mas_equalTo(0);
    }];
    
    UILabel *tipL = [RanTool labelWithFontSize:Zoom(16) weight:1 color:[RBThemeConfig textBlackColor] align:0 text:@"请在此处填写，您在使用的过程中出现的问题"];
    [topView view_addView:tipL withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(24) bottom:CGFLOAT_MIN left:Zoom(18) right:Zoom(18) centerX:0];
    
    RBTextView *textView = RBTextView.new;
    textView.placeHolderColor = [UIColor colorWithHexString:@"#ACACAC"];
    textView.placeHolderFontSize = Zoom(14);
    textView.placeHolder = @"点击此处填写详细信息";
    textView.font = [UIFont systemFontOfSize:Zoom(14)];
    textView.textColor = [RBThemeConfig textBlackColor];
    self.textView = textView;
    [topView view_addView:textView withHeight:Zoom(200) width:CGFLOAT_MIN top:Zoom(13) bottom:Zoom(20) left:Zoom(18)-7 right:Zoom(18)-7 centerX:0];
    
    UILabel *commitBtn = [RanTool labelWithFontSize:15 weight:0 color:[UIColor whiteColor] align:1 text:@"立即提交"];
    commitBtn.backgroundColor = [UIColor colorWithHexString:@"#518CFF"];
    [commitBtn rbSetCornerRadius:Zoom(22)];
    [commitBtn rbAddTapGesWithTarget:self action:@selector(commitBtnTapped)];
    [self.view addSubview:commitBtn];
    [commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Zoom(17));
        make.right.mas_equalTo(-Zoom(17));
        make.height.mas_equalTo(Zoom(44));
        make.bottom.mas_equalTo(-MAX(Zoom(25), kRBSafeBottomHeight));
    }];
    
}

#pragma mark - Network

#pragma mark - Event

- (void)commitBtnTapped
{
    if(!self.textView.text.length)
    {
        [self.view showTip:@"请输入反馈内容" completion:nil];
        return;
    }
    __weak typeof(self) weak_self = self;
    [self viewLoadDataWithParam:^(NSMutableDictionary *dicM) {
        dicM[@"content"] = self.textView.text;
    } path:@"han_user_feedback" post:YES log:YES responseClass:RBResponse.class desView:self.view showHud:YES showPlaceHolder:NO sucBlock:^(id data) {
        [weak_self.view showTip:@"您的反馈已提交" completion:^{
            [weak_self.navigationController popViewControllerAnimated:YES];
        }];
    } failBlock:^(RBResponse *data) {
        [weak_self.view showTip:data.message completion:nil];
    } reloadBlock:nil];
}

#pragma mark - Setter

#pragma mark - Getter

@end
